import { _decorator, Component, Node,Label,log,director } from 'cc';
const { ccclass, property } = _decorator;
import { Stage } from './Stage';


@ccclass('Game')
export class Game extends Component {
    @property(Stage)
    private stage: Stage = null;
    @property(Label)
    private scoreLabel: Label = null;

    private score: number = 0;

    protected start() {
        this.startGame();
    }

    public addScore(n: number) {
        this.score += n;
        this.scoreLabel.string = this.score + '';
    }

    public startGame() {
        this.score = 0;
        this.scoreLabel.string = '0';
        this.stage.init(this);
    }

    public overGame() {
        log('game over');
    }

    public restartGame() {
        director.loadScene('game');
    }

    public returnMenu() {
        director.loadScene('menu');
    }

    private onBtnOne() {
        this.stage.playerJump(1);
    }

    private onBtnTwo() {
        this.stage.playerJump(2);
    }
}

